Monday, December 01, 2008     | Register
TradersStudio Forums
Subject: Importing Scripts

You are not authorized to post a reply.   
Author Messages
chrisl
Posts:4

01-01-2007 1:57 PM Alert 
    I'm trying to import to scripts and am having trouble doing that. I'm specifically trying Ryan Jones Fixed Ratio. How can I import it from easylanguage to a script? It only comes in as a function, and I can't seem to access it in trade plans.
Thanks,
Chris
murray
Posts:431

01-02-2007 11:08 AM Alert 
You need to save the code as a Trade Plan function when you create file new in the editor.
chrisl
Posts:4

01-06-2007 5:27 PM Alert 
Thanks, I think I'm getting there. I'm new to object oriented programming. This code came via VanTharp readings. You risk 2% of equity till a trade wins, then you risk 2% + that profit, up to 7%. Please criticise my code. I'm looking to go up the VBasic learning curve. I pup some comments in the code also.
Thanks,
Chris



' Percent Margin Plan
' TradersStudio(r) (c) All rights reserved

Sub TS_1stTharp01(MinMarg,MaxMarg)
Dim S As Integer
Dim M As Integer
Dim DollarPerTrade
Dim NumberOfMarkets
Dim DollarsPerMarket
Dim PrevTrade As Integer
Dim PrevTradeProf As Integer
Dim StartAccount
Dim MinMargDoll As Integer
Dim MaxMargDoll As Integer
If tradeplan.MarketType<>0 Then
MsgBox("This trade plan can only be run on a Commodities,Futures")
StopRun
End If
If Tradeplan.SummEquity MsgBox "not enough money"
StopRun
End If
If Tradeplan.SummEquity< Tradeplan.TotalMarginForPlan Then
MsgBox "Margin Call Account below minimum margin required"
StopRun
End If

NumberOfMarkets=TradePlan.MarketCount
DollarsPerMarket=tradeplan.SummEquity/NumberOfMarkets
' Loop though all the sessions
For S = 0 To TradePlan.SessionCount - 1
TradePlan.Session(S).UnitSize = 1
' For each session Loop though the trading plans.
For M = 0 To TradePlan.Session(S).MarketCount - 1
If DollarsPerMarket>TradePlan.Session(S).Market(M).Margin Then
PrevTrade = LiveTradeCount - 1
PrevTradeProf = GetInfoaboutTrades(13,PrevTrade)
MinMargDoll = Tradeplan.SummEquity x (MinMarg/100)
MaxMargDoll = Tradeplan.SummEquity x (MaxMarg/100)
'gets % of present total equity you want to risk on trade
If PrevTradeProf < = 0 Then
TradePlan.Session(S).Market(M).EntryNumUnits =
MinMargDoll / TradeRisk
'is TradeRisk set internally for each system exit upon entry?
RecentTradeProf = 0
End If
'this means if last trade a loss reset your count of recent profits(pocket into closed trades) and only risk min
If PrevTradeProf > 0 Then
RecentTradeProf = RecentTradeProf + PrevTradeProf
TradePlan.Session(S).Market(M).EntryNumUnits =
(Min(MinMargDoll + RecentTradeProf, MaxMargDoll))/ TradeRisk
End If
'if last trade made a profit, add profits since last loss and risk them along with MinMarg, up to MaxMarg
Else
TradePlan.Session(S).Market(M).EntryNumUnits=0
End If
TradePlan.Session(S).Market(M).ExitNumUnits=TradePlan.Session(S).Market(M).NumContractsHeld
Next
Next
End Sub
murray
Posts:431

01-06-2007 5:37 PM Alert 
The code mixes functions which can be only called from sessions with ones which can only be called from trading plans. I will take a look at it and fix it. I will post it soon on this forum.
You are not authorized to post a reply.



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