NexusFi: Find Your Edge


Home Menu

 





Re-short after making a new high of day


Discussion in EasyLanguage Programming

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




 
Search this Thread

Re-short after making a new high of day

  #1 (permalink)
thinkorn00b
stavanger
 
Posts: 19 since Sep 2020
Thanks Given: 1
Thanks Received: 1

Hi

So I have this code that sell short when two conditions are met:

 
Code
Variables: 
SynOpen( 0 ),    
SynClose( 0 ), 
 
 
SynOpen  = (SynOpen[1]+SynClose[1])*.5;    
SynClose = (Open+High+Low+Close)*.25; 
 
Condition1 = (High[0] = HighD(0)) 
If Condition1 then begin  
Ashisignal = true; 
end; 
 
Condition2 = (SynClose <= SynOpen)
This short the stock at market price at the next red candle.

I want to re-short (if I take a win) when the price goes above the "high of the day follow by a red candle" (condition 1 and 2).
With the same criteria as in condition 1 and 2.
What the code does now is to re-short again after the first red candle without the stock making a new high of day.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Quant vue
Trading Reviews and Vendors
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #2 (permalink)
arni
Hamburg, Germany
 
Posts: 5 since Dec 2021
Thanks Given: 1
Thanks Received: 2

You could probably have a new variable that always saves the high of the current candle if it is higher than the high of the previous one. You could then build a condition around that for your entries. For example, lets say your candle N is a bear candle and the high of candle N-1 equals your variable, then you have an entry signal.

Reply With Quote
  #3 (permalink)
thinkorn00b
stavanger
 
Posts: 19 since Sep 2020
Thanks Given: 1
Thanks Received: 1



arni View Post
You could probably have a new variable that always saves the high of the current candle if it is higher than the high of the previous one. You could then build a condition around that for your entries. For example, lets say your candle N is a bear candle and the high of candle N-1 equals your variable, then you have an entry signal.

Thank you, however my problem with that way to write the code is that once the position is covered, and the price has not gone over HOD again, the condition is still valid, so it will re-short below HOD. It should only short once below HOD. For a second short the stock needs to break HOD again.

Reply With Quote
  #4 (permalink)
arni
Hamburg, Germany
 
Posts: 5 since Dec 2021
Thanks Given: 1
Thanks Received: 2


thinkorn00b View Post
Thank you, however my problem with that way to write the code is that once the position is covered, and the price has not gone over HOD again, the condition is still valid, so it will re-short below HOD. It should only short once below HOD. For a second short the stock needs to break HOD again.

Well, I see I have phrased my idea incorrectly. You would probably want to set an initial high to a variable and only if any successing candle has a high that is higher than that variables value, save the new high to the variable.

So maybe declare a variable "HOD" and set it to the high of the opening candle. Then, if any successing high is higher than the current value saved to your variable "HOD", set the variable to that new highs value. So basically do not compare candle N to candle N-1 like I said in my first post, but instead, compare the high of candle N to the value of "HOD" variable. Hope this makes more sense.

That way, it should only consider a new high of day where there is an orange arror in the picture below.

Reply With Quote
  #5 (permalink)
thinkorn00b
stavanger
 
Posts: 19 since Sep 2020
Thanks Given: 1
Thanks Received: 1


arni View Post
Well, I see I have phrased my idea incorrectly. You would probably want to set an initial high to a variable and only if any successing candle has a high that is higher than that variables value, save the new high to the variable.

So maybe declare a variable "HOD" and set it to the high of the opening candle. Then, if any successing high is higher than the current value saved to your variable "HOD", set the variable to that new highs value. So basically do not compare candle N to candle N-1 like I said in my first post, but instead, compare the high of candle N to the value of "HOD" variable. Hope this makes more sense.

That way, it should only consider a new high of day where there is an orange arror in the picture below.

Hi, well this is the part of the code I'm struggeling with, how to save the high of the high of the day, and make the code code execute again if a value is above that high. Also for the first short, it needs to execute without even though there hasn't been a high that is saved, as its the first high of the day. The code needs to reset each day.
The way I define the high of the day, is as seen in the code is when the red candle follow the green candle (which is the HOD).

Reply With Quote




Last Updated on October 23, 2022


© 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