entry price long above close of pinbar
Forums › ProRealTime English forum › ProOrder support › entry price long above close of pinbar
- This topic has 11 replies, 3 voices, and was last updated 1 year ago by jellevisser.
-
-
08/19/2023 at 8:00 AM #219326
Hello,
I would like some help with the following. I created an indicator which is looking at VSA and pinbar if the conditions are met indicator = -1. (long signal)
Now I would like to that when indicator is -1 at the next candle it buys 1 contract at entry (entry = close + 10 pips) below is the code, it is not working because it is not opening a position at all, i tried different things but i dont get it working.
How should i write the code in order that it works? many thanks in advance
// Definitie van code parameters
DEFPARAM CumulateOrders = False // Opstapelen posities gedeactiveerd// Condities om long posities te openen
indicator1 = CALL “VSA_final pinbar”
c1 = (indicator1 = -1)
entry = close[1] + (10*pipsize)IF c1 and tradeprice > entry THEN
BUY 1 CONTRACT AT market
ENDIF// Stops en targets
SET STOP pLOSS 25
SET TARGET pPROFIT 5008/19/2023 at 11:05 AM #219328Hi Jelle,
I set the indicator “VSA_final pinbar” for the test to -1…
After that, you need to enter the “entry” under an “If… then” statement otherwise it changes constantly when processing a new “Close”…
You cannot use “tradeprice > entry” here because the “tradeprice” only exists after opening a “trade”… instead of “tradeprice”, use the “Close”…
VSA final pinbar1234567891011121314151617181920// Definitie van code parametersDEFPARAM CumulateOrders = False // Opstapelen posities gedeactiveerd// Condities om long posities te openen//indicator1 = CALL "VSA_final pinbar"c1=indicator1 //c1 = Call "VSA_final pinbar"indicator1=-1 //Only for testingIf c1 = -1 thenentry = close[1] + (10*pipsize)EndIfIF c1 and Close > entry THENBUY 1 CONTRACT AT marketENDIF// Stops en targetsSET STOP pLOSS 25SET TARGET pPROFIT 5008/19/2023 at 11:41 AM #219329Hello JS
thanks for your reply, i tested your proposal but i can see that it still buys at market after the pinbar is formed and not 10 pips higher than close.
I attached a screenshot for clarification, any other suggestions?
I tried to add an attachment but is apparently not working, I hope it is clear what i mean.
08/19/2023 at 12:09 PM #219330Hi Jelle,
The system buys “at Market” because your code says “Buy 1 contract at Market”… 🙂
If you want to buy at the previous close + 10*pipsize then you have to use a STOP order…
VSA pinbar1234567891011121314151617181920// Definitie van code parametersDEFPARAM CumulateOrders = False // Opstapelen posities gedeactiveerd// Condities om long posities te openen//indicator1 = CALL "VSA_final pinbar"c1=indicator1 //c1 = Call "VSA_final pinbar"indicator1=-1 //Only for testingIf c1 = -1 thenentry = close + (10*pipsize)EndIfIF c1 and NOT OnMarket THENBUY 1 CONTRACT AT entry STOPENDIF// Stops en targetsSET STOP pLOSS 25SET TARGET pPROFIT 5008/20/2023 at 4:19 AM #219357Jelle, according to what you designed yourself, this is what resembles that :
1234567891011121314151617// Definitie van code parametersDEFPARAM CumulateOrders = False // Opstapelen posities gedeactiveerd// Condities om long posities te openenindicator1 = CALL “VSA_final pinbar”c1 = (indicator1 = -1)entry = close[1] + (10*pipsize)IF c1 and close > entry THEN // No TradePrice but Close.BUY 1 CONTRACT AT marketENDIF// Stops en targetsSET STOP pLOSS 25SET TARGET pPROFIT 50Graph Indicator1 // Check for whether the Indicator outcome does what you intend.If it now does not work, it will be because of wrong logic – not because of technicalities.
08/23/2023 at 4:14 PM #219574Hi Peter,
I think my logic is not correct, but how do i write the code different so that it opens a position 10 pips below the close (for short) of the pinbar?
08/24/2023 at 6:37 AM #219605Hi again Jelle,
1234567891011121314151617// Definitie van code parametersDEFPARAM CumulateOrders = False // Opstapelen posities gedeactiveerd// Condities om long posities te openenindicator1 = CALL “VSA_final pinbar”c1 = (indicator1 = 1) // Is this correct for Short ?entry = close[0] - (10*pipsize) // Changed [1] to [0] and + to -.IF c1 and close < entry THEN // It is not said that you want it like this.SellShort 1 CONTRACT AT marketENDIF// Stops en targetsSET STOP pLOSS 25SET TARGET pPROFIT 50Graph Indicator1 // Check for whether the Indicator outcome does what you intend.“It is not said that you want it like this”. Why ?
You first seem to wait until the price is extra-low, and then go Short (SellShort). This seems counter-productive, though obviously it can be part of your strategy.
My senses tell me this :You have that Indicator (with for us unknown content) and it tells to go Short. What I would do is wait for the better price, which would be a higher price than the price at the moment of the Indicator telling you to go Short. Notice that you are always one bar behind. Thus for example, when the Indicator tells you that you can go Short, and the TimeFrame is 1 minute (the chart is set to bars of 1 minute) then 1 minute late you will “see” this (the program code is called at the end of each bar hence minute).
What’s crucial for the consistency are this considerations :
- When the Indicator tells to go Short, the price could be dropping more and my “senses” above are wrong and won’t apply (no price will be higher than when the indicator “detected” and you will wait forever for an entry.
- When the Indicator tells to go Short, it may be better not to look for an even lower price, because within that past minute it may never have happened.
Taking both into consideration, this would work best :
123IF c1 THEN // So just depend on the Indicator.SellShort 1 CONTRACT AT marketENDIFBut always watch the outcome of Indicator1 (with graph) because if that is not doing what you expect (it may remain 0 always) then no entry will be there ever.
Also, maybe ensure yourself that the Indicator returns -1 indeed for Long (and I suppose 1 for Short then) because it does not seem logical to me (-1 for Short would be logical to me).Have fun !
Peter08/24/2023 at 8:21 PM #219759Hi Peter,
this is the code I use, when green pinbar in combination with VSA it give signal -1 for long and red pinbar with VSA 1 for short.
so if a green pinbar is formed it gives a signal of 1 and next candle the program buys a long, this strategy works reasonable but i see too often that when a green pinbar is formed the price drops further. I would like to have a condition that if a green pinbar is formed and the close of the pinbar is lets say 100 that the program on the next candel buys one long contract at 110. in the example when a green pinbar is formed and the close is 100 and the next candel drops below 100 the program should not buy and wait for the next opportunity.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495//met pinbar alleen long als pinbar groen is en short als deze rood isc1= open - closec2= open[1]-close[1]if c1 < 0 thenc1 =(open - close)*-1elsec1 =(open - close)endifif c2 < 0 thenc2 =(open[1]-close[1])*-1elsec2 =(open[1]-close[1])endifif (c1<c2) thenVSAkoers =1elsevsakoers = 0endif//correctie voor volumeindicator1 = Volumec3 = (indicator1 > indicator1[1])if indicator1 > indicator1[1] thenVSAvolume = 1elseVSAvolume = 0endif//correctie voor low van de x periods indicator voor long signaalc4 = lowest [5](low)if low <c4 [1] thenVSAlow = -1elseVSAlow = 0endif//correctie voor high van de x periods indicator voor short signaalc5 = highest [5](high)if high > c5 [1] thenVSAhigh = 1elseVSAhigh = 0endif//groene pinbar voor long / rode pinbar voor shortpinbarcolor = 0if open < close thenpinbarcolor = 1 //short signaalelsepinbarcolor = -1 // long signaalendif//correctie voor pinbarshootingstar = 0hammer = 0IF (high - low) > 2* abs(close - open) THENIF (open - low) < 0.4*(high - low) OR (close - low) < 0.4*(high-low) THENshootingstar = -1ENDIFIF (high - open) < 0.4*(high - low) OR (high - close) < 0.4*(high-low) THENhammer = 1ENDIFendifc8 = close[1]- close [5] //distance from candle 5 to 1 for shortif c8 > 10 thenc8 = 1elsec8=0endifc9= close[5]- close [1]//distance from candle 5 to 1 for longif c9 > 10 thenc9 = 1elsec9=0endif//final voorwaardenif VSAkoers =1 and VSAvolume = 1 and VSAhigh=1 and shootingstar = -1 and pinbarcolor = -1 thenVSA=1 //short signaalelseif VSAkoers =1 and VSAvolume = 1 and VSAlow=-1 and hammer = 1 and pinbarcolor = 1 thenVSA=-1// longsignaalelseVSA=0endifendifreturn VSA as "VSA"08/26/2023 at 9:30 AM #219798Hi Jelle,
It would be nice if you coded that indicator yourself – then we could try to let it work. I (also) mean : I like to have it working myself. Why ? see the first picture below.
The purple down-arrow in the left hand side is yours. The yellow down-arrow in the right is mine. Notice that the pinbar I use is the bar prior to the bar prior to the entry. Thus, green in order to go short. Yours is red in order to go short, and I don’t think that is right. However, I personally go mad of upside-down thinking (what this requires) in general. Thus, the “I don’t think that is right” is actually not wrong, BUT see the 4th picture and try to wrap your head around why it is different. And why mine (yellow) looks better for start-off (keep in mind I use two bars to get to the decision).
Notice that I did not apply further code after calling the indicator. You, in your original post did, but I don’t think that is entry related – only best entry. I do similar in my general code and it is applied to your entry just as well.EXPLANATION
I coincidentally apply the same “pinbar” method but by very different (incomparable) means. The backtest result of my method you see in the 2nd picture. Your backtest result shows in the 3rd picture.
Notice that the code for both your and my method is completely the same – only the pinbar method was replaced hence only the entry-means was replaced.
Your method is heavily Short oriented, which can’t be reality (this is EUR/USD and nothing in my book tells that it should be short-oriented, even if the EUR is falling gradually lately. This is not how the pinbar method would operate, on the 1 minute TimeFrame I use. So something has to be wrong in the basis.
If you have made this code yourself, I would be nice if you put as much comment in there as you can bear. This should lead to finding the culprit(s). Anyway I can’t read it as how it is, because I did not dive into how this method should really be approached (and I don’t give myself the time to find out 😉 ).In any event the entries are there, so nothing wrong with that in itself.
Regards,
Peter08/26/2023 at 8:42 PM #219816Hi Peter,
I wrote the code myself, it has to be optimized. I am struggling with the settings for stoploss and profit. I use it now as an entry, as soon the program buys i stop the program and manage the trade my self because i can have a much better exit.
But you have a nice program that makes a profit! impressive result
if I look at the your first picture it looks like it is buying a certain amount of pips above the previous close I cant see by how much, but if I backt test mine it always buys at market.
why should the EUR/USD not be shorted? just for my interest I am still learning about trading.
08/27/2023 at 4:54 AM #219819About the Buy at Market : see JS’s response. Thus the answer is simple : because you give the command to buy At Market (price). Buy at xx Limit (JS uses Stop) would wait for the price to go there and if touched, it buys. And Yes, I use at xx Limit there too.
Of course EUR/USD can be shorted, but your Indicator makes it Short-Heavy. With that I mean that there’s way more Shorts than Longs, and that is not right. It should balance-out (about-ish). And since it does not, something has to be wrong (x – close vs close – x or something). Btw, if you swap the signals (to 1 for Long and -1 for Short) it performs better – usually no a good sign ;-).
As said, if you put comments to everything, I can try to let it work, also based upon (PRT) experience. Comments like “0.4 means at least 40% of the candle must be the wick size” (just making up something).
It is not an easy indicator to work with because you can have many false indications, like what the descriptions will tell you “don’t use it in the middle of a consolidation” (these are often spikey to begin with and go nowhere until …). So it is key to know that, and soon you will run into endless trials to cover for that. What you saw from my example screenshot covers for that as far as I got it at this moment, but … your Pinbar indicator made use of that very same environment (as said, it is within the same code, only the Entry “Pinbar” method was replaced by yours).
Small hint : entry means like these will lead to many losing trades (like more than 50%) but this is fine as long as the P/L Ratio is OK (net you win more money than you lose). IOW don’t be disappointed if your Winning Trades % remains low. Later (if the net result is consistently positive) you just throw more money at it.
In case you don’t know it yet : Replace your SET STOP pLOSS 25 with SET STOP pLOSS pLossVar and put pLossVar in an iterating Optimization Variable (see the wrench in the top-left of the Editor screen). Let it vary from 1 to 100 and observe the results. Same with the profit target. Same with everything …
And have fun …
1 user thanked author for this post.
08/27/2023 at 9:17 AM #219831Hi peter,
thanks for you support and help. I will continue in the end it will work, I hope.
-
AuthorPosts
Find exclusive trading pro-tools on