STOP LOSS
Incorporating a value stop; from the open trade price into EFS for, trading the SPOT FOREX Market.
Currently the EFS code calls for all open positions to close and reverse when the opposite signal occurs within the EFS file.
However, incorporating some conditional EFS code to, have all open positions close if a value stop is reached prior to an opposite signal occurring would be preferred.
Therefore, what conditional EFS code would exit all open long or short positions based on a negative value from the opening price of that open position. Long example; close this position if the market price is less than the open price minus 50 pips or close this position if a short entry signal is triggered. Short example; close this position if the market price is greater than the open price plus 50 pips or close this position if a long entry signal is triggered.
Several attempts have been made to modify the ”BtDonchian_FixedStops.efs” file that can be found on this site. However, none of these attempts produce the results needed.
In the meantime, below is the EFS code from the EFS Action Section of the EFS file that, opens both long and short position after all conditions are met on both Action 1 and Action 2.
//{{EFS_Action_1
function onAction1() {
drawTextRelative(0, low(-1), "A", Color.RGB(0,0,255), Color.RGB(255,255,255), Text.BOLD, "Arial", 12);
Strategy.doLong("AN", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 1;
}
//}}EFS_Action_1
//{{EFS_Action_2
function onAction2() {
drawTextRelative(0, high(-1), "A", Color.RGB(255,0,0), Color.RGB(255,255,255), Text.BOLD, "Arial", 12);
Strategy.doShort("AS", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 1;
}
//}}EFS_Action_2
Incorporating a value stop; from the open trade price into EFS for, trading the SPOT FOREX Market.
Currently the EFS code calls for all open positions to close and reverse when the opposite signal occurs within the EFS file.
However, incorporating some conditional EFS code to, have all open positions close if a value stop is reached prior to an opposite signal occurring would be preferred.
Therefore, what conditional EFS code would exit all open long or short positions based on a negative value from the opening price of that open position. Long example; close this position if the market price is less than the open price minus 50 pips or close this position if a short entry signal is triggered. Short example; close this position if the market price is greater than the open price plus 50 pips or close this position if a long entry signal is triggered.
Several attempts have been made to modify the ”BtDonchian_FixedStops.efs” file that can be found on this site. However, none of these attempts produce the results needed.
In the meantime, below is the EFS code from the EFS Action Section of the EFS file that, opens both long and short position after all conditions are met on both Action 1 and Action 2.
//{{EFS_Action_1
function onAction1() {
drawTextRelative(0, low(-1), "A", Color.RGB(0,0,255), Color.RGB(255,255,255), Text.BOLD, "Arial", 12);
Strategy.doLong("AN", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 1;
}
//}}EFS_Action_1
//{{EFS_Action_2
function onAction2() {
drawTextRelative(0, high(-1), "A", Color.RGB(255,0,0), Color.RGB(255,255,255), Text.BOLD, "Arial", 12);
Strategy.doShort("AS", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 1;
}
//}}EFS_Action_2
Comment