Good evening everyone,
as in the attached screenshot (1 minute timeframe), I would like to insert in the code not to go in a long position if a price has not been formalized / there is no bar in the frames prior to the purchase (frames indicated in the red circle).
How can the sw take over that there is no slash?
Thanks a lot for those who want to give me a tip!
I don’t know if i well understood your question, but i try to make a guess.
EntryOnlyIf1= close>close-1
EntryOnlyIf2= close<close-1
if yourconditions and EntryOnlyIf1 and EntryOnlyIf2
then buy\sellshort n contracts at market
endif
Please do not double post.
I will delete the other one.
If markets are closed then no bar will appear. If they are open you can tell if there is a bar or not if close=open and there are no shadows. Open, High, Low and Close will all have the same price.
I would like that in case of lack of slash (candle), the sw did not go long. I tried to write the following code but nevertheless the sw continues to go long. Where am I wrong?
In attachment I send the screenshot of the functioning of my code. Where there is the vertical red line, in that minute, there is no candle and therefore I would not want it to go long (as it does instead)
Thank you very much!
// Definition of code parameters
MyRange = Range
Dojistretta = (Open=Close)
Assenzadicandela = (High = Low)
REM Vai LONG se:
// - se non c'è una doji ristretta o con range nullo nella posizione precedente all'acquisto
// - non siamo oltre le 17.20
// allora vai long
IF NOT LONGONMARKET AND MyConditions AND NOT MyRange = 0 AND NOT DOjistretta AND NOT Assenzadicandela THEN
BUY 1000 SHARES AT MARKET
ENDIF
As from your pic it seems there are no empty bars, just there are NO bars, so the entry bar (the red one) is simply the next one following the green bar.
The attached pic shows empty bars (the one you want to skip) circled, while NO bars (which you cannot detect since they are NOT bars) in a rectangle. In your case your bars were like those in the rectangle, simply there was none!
You should always let us know:
- instrument traded (FX pair, Indices, stocks….)
- TF used
- date & time of involved candlesticks
to be able to check and replicate your trades.
Exactly, that was what I was trying to explain to you.
I don’t want to go long when there are no bars (rectangles in your image) in the previous minutes, is that possible?
What does TS mean?
TF = Time Frame (1 minute, 4 hours, Daily, ec…).
Indeed it does not enter on a NON-existing candle, it enters the next candle, as usual.
If your conditions are met on the last candle on Friday, a trade will be opened on Monday (or Sunday) when the markets re-open.
Code is read at Close of your big green candle and order is launch at next bar Open. At Close of the green bar, there is no way to know what happen next, so the order is logically opened at next opening bar.