Tuesday, November 18, 2008     | Register
TradersStudio Forums
Subject: Programing Question

You are not authorized to post a reply.   
Author Messages
alec
Posts:5

08-03-2008 12:22 AM Alert 

I am a newbie and trying to learn TradeStudio Basic without previous knowledge of either VB or QBasic..or Easy Language.

Question: 

I am playing aroud and trying something simple like : Buy when CCI crosses 30 and Sell when CCI crosses 70.  I am trying to program it so that if yesterday was below 30 but today crosses 30 then buy...I just can't seem to find a way to make it work when I add the CloseΏ] or CloseΎ]...

Can anyone help?...

Sub CCItest (Period, Offset)
    Dim SignalName
    Dim Size
    Dim Price
    Dim OrderType
    Dim OrderTime

    If CCI(Period, Offset) > 30 Then
        Buy(SignalName, Size, Price, OrderType, OrderTime)

murray
Posts:431

08-03-2008 8:56 AM Alert 

This example should help , notice the indicator values are saved to variables which are type bararray , then you can access past values

 

'********************************
' Simple Dual moving average crossover
' TradersStudio(r) 2004-2007 , All rights reserved

Sub MovingAveSystem(SLen As Integer, LLen As Integer)
    Dim ShortAve As BarArray
    Dim LongAve As BarArray
    ShortAve = Average(Close, SLen,0)
    LongAve = Average(Close, LLen,0)
     If ShortAve > LongAve And ShortAveΏ] < LongAveΏ] Then
        Buy("BuyEnt",1,0,Market,Day)
    End If
    If ShortAve < LongAve And ShortAveΏ] > LongAveΏ] Then
        Sell("SellEnt",1,0,Market,Day)
    End If
End Sub

alec
Posts:5

08-12-2008 11:38 AM Alert 

Thanks Murray.  That helped.

I have another question:

...about the Floor/Ceiling functions..... 

Floor/Ceiling;  as in when a Moving Average curve is tangent to the horizontal?

 

thanks

murray
Posts:431

08-12-2008 12:11 PM Alert 

No, Like Rounding.

4.1 becomes 4.0 with the floor and 4.1 becomes 5.0 with ceiling.

You are not authorized to post a reply.



ActiveForums 3.6
TradersStudio® Copyright 2004-2008 All Rights Reserved   |  Privacy Statement  |  Terms Of Use