ET News & Sponsor Info
General Topics
Markets
Technical Topics
Brokerage Firms
Company Specific
Tools of the Trade
Trading for a Living
Community Lounge
Site Support

# Need help to code

Discussion in 'Strategy Building' started by scrtrade, Aug 9, 2005.

1. Good morning,
my idea is the following:
Count the bars since the opening until my indicator1=100.
If myindicator1=100 the 7th bar then i want to buy if price>highest high of the 1st to 7th bar. And sell if the price< lowest low of the 1st to 7 bar.So It is a very simple and basic idea.

I tried to code like this:
VARS:
count(0),
countstop(0),
sellsignal(0);

If date<>date then begin
If myindicator1<100 then count=count+1;
If myindicator1=100 then countstop=countstop+1;
If countstop=1
End;
If countstop=1 then value1=count;
sellsignal=lowest(low,value1);
If close<sellsignal the sell;

If later in the same day myindicator1=100 again, it is not to be calculated. The value1 is fixed once for the all day. I'm just interested for the first time it occurs in the same day.

Thanking you,
SCR

2. Remember to reset your counter at the end of the day back to zero for the following day.

Somethig like...if time=1600 then count=0;

I'll try this and let you know the result.

Bye.

4. Unfortunately, it does'nt work.

I want that the Highest High and Lowest low since the opening, at the moment when
myindicator=100 for the first time this day since the opening. And this Highest high and the lowest low would be my pivotpoint of the day, even if some times later myindicator=100 again, this does'nt matter and the pivotpoint must not change for the day.
This pivot point must be calculated every day since the opening of the day untill my indicator=100 for the first time of the day.

I try this one but it is worst.

If time>0930 and myindicator<100 then count=count+1;
If time>0930 and myindicator=100 then count=0;
If count>0 and count=0 then value1=count
If time=1600 then count=0;

Sellsignal=lowest (low, value1);

If close<sellsignal then sell;
If marketposition=1 and time=1600 then exitlong,
If marketposition=-1 and time=1600 then exitshort;

My difficulty is that I try to calculate the value of value1 for each day and I fail!

Thanks again for your help,
SCR.

5. Up !

Thanks.

6. What is myindicator1? Why you use it
Why there is no action after "If countstop=1"?
If close>buysignal then buy; is also wrong

Your way of coding is not easy to understand
for most, or maybe it's me. I think it's good
idea to put {commentary} for some lines

7. You are using Tradestation, right?

8. My indicator is a modified Stochast indicator .

When the Stoch is >=90 for the first time in the day, say for exemple at 09:47, then in this case, I want that my system give for the "buysignal" the value of the highest high between the opening and the 17th bar, and for the "sellsignal" the lowest low between the opening and the 17ht bar, in the case of a 1min bar chart.
In this case my "buysignal" for the day would be the highest high of the 17 first bars of the day, and i will buy if
there is a close>of the buysignal. And sell if close under the "sellsignal".

Once this two values (buysignal and sellsignal) are fixed, for the first time in a day, they must be the same for the whole day, even if the Stoch indicator is >=90 25 min later. I don't want to take in count the new highest high and the new lowest low.

The next day at the open, the counter must be at zero and wait that the stoch is >=90 to assign a new value for the highest high and the lowest low. If the stoch is >=90 at the 48th minutes, then my "buysignal" would be the highest high of the 48 first bars of the day and the sellsignal would be the lowest low of the 48 first bars of the day.

I hope that it's more understandable!

Thank you .

9. For hanseng1,

yes.

I am not the most efficient coder, so this can probably be written more concisely, but try this. It is written for TS 2000i, so if you are using TS8 you may need to modify it a bit. Also, I used a simple %R signal for the trigger, you will need to replace it with your indicator. The first section of code is the signal, the second part is an indicator that will plot the buy and sell levels.

I did not completely understand your rules, so I made some assumptions with the code. The buy and sell levels remain valid all day once they are in place, so if it triggers a buy and then trades back down to the sell level it will reverse and go short. All trades are exited on the close, so there are no stops (other than the reversal on an opposite signal) or profit targets.

{*****Begin Code*******}
Inputs: Length(14);
Vars: Count(0), buySignal(0), sellSignal(0), noMoreSig(false);

If date<>date then begin
sellSignal = 0;
Count = 0;
Condition1 = false;
noMoreSig = false;
End;

{*****Enter your own indicator trigger here******}
If PercentR(Length) > 90 then begin
Condition1 = true;
End;
{**********************************}

If Condition1 = false then begin
Count = Count + 1;
End;
If Condition1 = True and Condition1 = False and NoMoreSig = False then begin
sellSignal=Lowest(Low,Count);
noMoreSig = true;
End;

If Close < sellSignal then Sell;

SetExitOnClose;

{*****End Code*****}

{*************************************************}

{*****Indicator Code******}
Inputs: Length(14);
Vars: Count(0), buySignal(0), sellSignal(0), noMoreSig(false);

If date<>date then begin
sellSignal = 0;
Count = 0;
Condition1 = false;
noMoreSig = false;
End;

{*****Enter your own indicator trigger here******}
If PercentR(Length) > 90 then begin
Condition1 = true;
End;
{**********************************}

If Condition1 = false then begin
Count = Count + 1;
End;
If Condition1 = True and Condition1 = False and NoMoreSig = False then begin
sellSignal=Lowest(Low,Count);
noMoreSig = true;
End;
If buySignal = 99999999 then NoPlot(1)
Else