Direction
1 : –
Waiting for prices
Enter direction, entry, stop loss and take profit. Minimum is 1 : 3.
After the trade closes, add the after screenshot and press Send to Google Sheet again. It updates the same row.
Google Sheet setup (one time)
- Create a new Google Sheet. Open Extensions, then Apps Script.
- Delete the sample code, paste the script below, and save.
- Click Deploy, then New deployment. Choose type Web app. Set Execute as to Me and Who has access to Anyone. Click Deploy and allow access.
- Copy the Web app URL, which ends in /exec, and paste it below. It is saved in this browser.
Script
function doPost(e) {
var lock = LockService.getScriptLock();
lock.waitLock(10000);
try {
var d = JSON.parse(e.postData.contents);
var sh = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
if (sh.getLastRow() === 0) {
sh.appendRow(['Trade ID', 'Saved at', 'Trade time', 'Pair', 'Direction', 'Entry', 'Stop loss', 'Take profit', 'Risk reward', 'Rules met', 'Rules not checked', 'Notes', 'Before screenshot', 'After screenshot']);
}
var row = [d.id, new Date(), d.time, d.pair, d.direction, d.entry, d.sl, d.tp, d.rr, d.rulesMet, d.notChecked, d.notes, d.before, d.after];
var found = 0;
var last = sh.getLastRow();
if (last > 1) {
var ids = sh.getRange(2, 1, last - 1, 1).getValues();
for (var i = 0; i !== ids.length; i++) {
if (String(ids[i][0]) === String(d.id)) { found = i + 2; break; }
}
}
if (found) sh.getRange(found, 1, 1, row.length).setValues([row]);
else sh.appendRow(row);
return ContentService.createTextOutput('ok');
} finally {
lock.releaseLock();
}
}