Price array as a condition
Author: leeto
Creation Date: 6/1/2015 7:55 AM
profile picture

leeto

#1
Could you help me ?
I need to make that specific strategy will be activated only around specific price array.

Let's take for example some default strategy :
CODE:
Please log in to see this code.



Where should I put price array in my code ?

I guess it should be looks something like this :

CODE:
Please log in to see this code.


profile picture

Eugene

#2
1. Before anything else, what does "Bars.Close[bar] > price_array" is used to mean? If the idea is to check if the current close is greater than any of the elements of the array, you can employ GetHighest routine from my reply #2 here:

How do you find the highest value in an array of numbers?

2. How about rephrasing this sentence as it's not clear what it means?
QUOTE:
and also I would like that current price be bigger than price from array between 0.12$ and 0.05$ // how can I integrate this condition correctly ?


3. The array may be defined as a class-level variable but it's not a requirement. You can define it inside the Execute() method's body, too.
profile picture

leeto

#3

2. Yes, sorry indeed should be clarification

for example

Let say
Price of "A" change from 3.5$ to 2.01$

I would like that before price of "A" reaches 3.33$ ( let say above 12 cents so it will be 3.45$) my algorithm start to check price action on needed to me condition in order to find point of opening potions. In addition, I would like that my algorithm turn off after 5 cents ( 3.28$) when pivot price point is pasted. Moreover, I would like again that my algorithm turn on when price action approach 2.22$ ( again 12cent above = 2.34$ ) and turn off 5 cents below 2.22$ ( 2.17$ )


price_array == [ 1.11 ; 2.22; 3.33; 4.44; 5.55; 6.66; 7.77 ; 8.88; 9.99 ]

So, price array for strategy just another one "if than condition". Please, could you tell me how would be code looks like ?
profile picture

Eugene

#4
Got it. Give this a try:

CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).