|
Amsterdam Netherlands
Posts: 52 since Aug 2020
Thanks Given: 13
Thanks Received: 22
|
I wasn’t able to find a relevant thread and hope someone can help me to improve my code.
I'm having trouble coding a basic Stop Loss strategy. The idea should be as follows:
1) Buy/Sell a contract in the NASDAQ 100 based on the actual strategy.
2) Set the Stop Loss to the previous bar's low/high before the trade entry bar. For example, if a trade opens at 12pm, the stop loss should be based on the 11pm bar (1H chart).
The SL moves with the trade, which causes problems. If the trade is still open after 1 hour and another bar is created, the SL moves to the next low/high bar. It should remain fixed.
Is it possible to use the Set StopLoss strategy, where the difference between the open price and the previous day's Low/High is calculated?
SetStopLoss (Entry – Low previous bar)
Is there a better way to set the stop loss? That is based on the total position, so if I trade more than one contract, I must modify the calculation by multiplying it by the contract.
|