NexusFi: Find Your Edge


Home Menu

 





Stop Loss last bar Low/High coding issues


Discussion in EasyLanguage Programming

Updated
    1. trending_up 847 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

Stop Loss last bar Low/High coding issues

  #1 (permalink)
FutureTrader112
Amsterdam Netherlands
 
Posts: 34 since Aug 2020
Thanks Given: 10
Thanks Received: 17

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.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
 
  #2 (permalink)
tyler803
columbia, sc
 
Posts: 3 since Nov 2022
Thanks Given: 0
Thanks Received: 5


FutureTrader112 View Post
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.

I'm not sure what language you are coding in and my only experience is using the ninjatrarer strategy builder. I would make a variable parameter and have it set when you enter position. The variable value would be the price at which you want to set the stop. Then you would tell it to exit the position if price goes above/below that set value and it won't follow the low/high of every bar after that

Reply With Quote
Thanked by:




Last Updated on February 19, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts