output a distinct value?
Forums › ProRealTime English forum › ProOrder support › output a distinct value?
- This topic has 6 replies, 2 voices, and was last updated 7 years ago by
Nicolas.
-
-
09/18/2017 at 12:44 PM #46496
Hello, I have problems with a complicated loop.
I think it would help me if someone could tell me whether the following is possible:
If I want to define a certain value like low [1] as selltrigger.
Is it possible to output this value as a concrete number,
in order to calculate with this number later in the process?
For example the low [1] was 89,10 EUR I want to code the Stop-Loss condition as:if close<89,10 then
Sell size SHARES AT MARKETI don´t want to code:
if close<low [1] then
Sell size SHARES AT MARKET!Thanks for help 🙂
09/18/2017 at 12:52 PM #46499You can store any value in a variable and use it later in your code:
123456789//firstly store the value in a variable whenever you wantif conditionToStore thenmyValue = Low[1]endif//then use this variable to trigger your 'stoploss' (exit condition here)if close < myValue thenSell size SHARES AT MARKETendif1 user thanked author for this post.
09/18/2017 at 1:37 PM #46501Hello Nicolas, thanks for your answer! Sounds great.
Unfortunately, it does not work for me. When I run the code, I always get the error: “conditiontostore is not defined”(in german: Die folgende Variable ist nicht definiert:conditionToStore”…
Any idea?
09/18/2017 at 4:41 PM #46526Hello again,
now I see that what I wrote above was nonsens. I missinterpreted “conditionToStore” as a comand….
Here is my lousy code (I know it is not good and can´t work this way…). But since I am a beginner, maybay someone could help me with my approach.
_________________________
1234567891011121314151617181920212223242526Hammeryes=0Hammerup=0Hammer = CALL Hammerif Hammer[1] = 1 thenHammeryes=1 and uptrigger=high[1] and downtrigger=low[1]endif//I want to check for the four following bars after the occurance of the Hammer if ONE of them could close obove the Hammer-High. If so, for exampel the 2nd one closed above, I want to break the check-up procedure.for i = 0 to 3 doif (close[i] < uptrigger) thenHammerup=Hammerupendifelseif (close[i] > uptrigger) thenHammerup=Hammerup+1endifbreakif Hammerup=1 thenBUY 1 SHARES AT MARKETendifif longonmarket and close < downtrigger thenSell 1 SHARES AT MARKETendif09/19/2017 at 7:50 AM #46551> For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text of the code part! Thank you! <<
If you want to trade the breakout of 2 defined levels, I suggest to use pending STOP orders instead. These pending orders will be set for the four following bars after an Hammer has been identified by the indicator you are “calling”:
1234567891011Hammer = CALL Hammerif Hammer[1] = 1 thenuptrigger=high[1] and downtrigger=low[1]hammerbar = barindex[1]endif//check if the hammerbar is defined and if the hammer occurred in the last 4 barsif hammerbar>0 and barindex-hammerbar<=4 thenbuy 1 contract at uptrigger STOPsellshort 1 contract at downtrigger STOPendifPlease test the code and make comments.
1 user thanked author for this post.
09/19/2017 at 12:43 PM #46591Thank you Niklas that helps me very very much!
Without you I would never have come to this solution!
Best wishes
Michael
09/20/2017 at 7:45 AM #46645I made a typo while copy/paste your code in my last post, the correct code should be:
123456789101112Hammer = CALL Hammerif Hammer[1] = 1 thenuptrigger=high[1]downtrigger=low[1]hammerbar = barindex[1]endif//check if the hammerbar is defined and if the hammer occurred in the last 4 barsif hammerbar>0 and barindex-hammerbar<=4 thenbuy 1 contract at uptrigger STOPsellshort 1 contract at downtrigger STOPendifSorry for inconvenience 😐
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on